package ma.ac.onousc.gestionfi.budget.model.DAO.DAOBean;

import java.util.List;

import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;

import ma.ac.onousc.gestionfi.budget.model.TypeBudget;
import ma.ac.onousc.gestionfi.budget.model.DAO.TypeBudgetDAO;

@Stateless
@TransactionAttribute(TransactionAttributeType.SUPPORTS)
public class TypeBudgetDAOBean extends GenericEJB3Bean<TypeBudget, Integer>
		implements TypeBudgetDAO {

	@SuppressWarnings("unchecked")
	@Override
	public List<TypeBudget> findAllTypeBudget() {
		return getEntityManager().createNamedQuery("TypeBudget.findAll")
				.getResultList();
	}

	@Override
	public TypeBudget findTypeBudgetByIntitule(String intitule) {
		return (TypeBudget) getEntityManager()
				.createNamedQuery("TypeBudget.findByIntitule")
				.setParameter("INTITULE", intitule).getResultList().get(0);
	}

}